package com.yanggu.mapreduce.manyjob;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @version V1.0
 * @author: YangGu
 * @date: 2020/2/8 21:00
 * @description:
 */
public class TwoJobMapper extends Mapper<LongWritable, Text, Text, Text> {

    private Text k = new Text();

    private Text v = new Text();


    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //atguigu--a.txt	3

        //1. 获取一行数据
        String line = value.toString();

        //2. 切割数据
        String[] fields = line.split("--");

        //3. 封装key和value
        k.set(fields[0]);
        v.set(fields[1]);

        //4. 写出
        context.write(k, v);

    }
}
